using System.Windows.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.Extensions.Configuration;

namespace HostWpfApp;

public partial class MainViewModel : ObservableObject
{
    private readonly Dispatcher _dispatcher;
    [ObservableProperty] private string logLevel = "未找到";
    [ObservableProperty] private string message;

    public MainViewModel(IConfiguration configuration, Dispatcher dispatcher)
    {
        _dispatcher = dispatcher;
        //读取appsettings.json中的配置
        logLevel = configuration["Logging:LogLevel:Microsoft"];
    }

    async Task FooAsync()
    {
        _dispatcher.Invoke(() => Message = "Hello World");
    }
}